package com.eascs.ticket.configuration.controller;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.site.page.PaginationInfo;
import com.eascs.site.page.SelectDataOption;
import com.eascs.site.view.ViewContext;
import com.eascs.site.view.button.Button;
import com.eascs.site.view.button.ButtonHelper;
import com.eascs.ticket.common.controller.BaseMasterViewController;
import com.eascs.ticket.configuration.entity.TicketType;
import com.eascs.ticket.configuration.form.ViewFlowForm;
import com.eascs.ticket.configuration.service.TicketTypeService;
import com.eascs.ticket.configuration.service.TicketTypeStatusService;

@Controller
public class TicketTypeViewController extends BaseMasterViewController {
	@Inject
	private TicketTypeService ticketTypeService;

	@Inject
	private TicketTypeStatusService ticketTypeStatusService;

	@RequestMapping("/configuration/ticket-type/list")
	public String list() {
		PaginationInfo ticketTypePaginationInfo = new PaginationInfo(this.ticketTypeService.getAllTicketType(), new String[] { "编码", "名称", "备注" });
		ticketTypePaginationInfo.setMoreButtons(new Button[] { ButtonHelper.createOpenButton("查看流程", "/configuration/ticket-type/viewFlow?ticketTypeId=") });
		ViewContext.put("ticketTypePaginationInfo", ticketTypePaginationInfo);
		return "configuration/ticketType/list";
	}

	@RequestMapping("/configuration/ticket-type/viewFlow")
	public String viewFlow(ViewFlowForm viewFlowForm) {
		TicketType ticketType = this.ticketTypeService.getTicketTypeById(viewFlowForm.getTicketTypeId());
		PaginationInfo paginationInfo = new PaginationInfo(this.ticketTypeStatusService.getTicketTypeStatusByTicketTypeCode(ticketType.getCode()), new String[] { "当前状态", "转入状态", "操作名称", "转移给", "备注", "排序号" });
		paginationInfo.setMoreButtons(new Button[] { ButtonHelper.createAjaxButton("修改", "/configuration/ticket-type/editFlow?ticketTypeStatusId="), ButtonHelper.createAjaxButton("删除", "/configuration/ticket-type/deleteFlow?ticketTypeStatusId=") });
		paginationInfo.setSelectDataOptions(new SelectDataOption[] { new SelectDataOption("ticketStatus"), new SelectDataOption("ticketStatus"), null, new SelectDataOption("after_assign_type") });
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("ticketType", ticketType);
		return "configuration/ticketType/viewFlow";
	}
}
